<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
 <link href="static/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="static/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="static/css/base.css" />
    <link rel="stylesheet" href="static/css/info-mgt.css" />
    <style>
        .layui-layer-title{background:url(images/righttitlebig.png) repeat-x;font-weight:bold;color:#46647e; border:1px solid #c1d3de;height: 33px;line-height: 33px;}
        .tabe_bot label{width: 70px;text-align: right;font-size: 14px;font-weight: 900;color: #46647e}
        .l_left{float: left}
        .tabe_bot input,.tabe_bot  select{width: 180px;height: 30px;border-radius: 6px;margin:0 20px 0 0;border: none;border: 1px #ccc solid}
        .tabe_btn{width: 60px;height: 30px;background-color: #68b86c;border: none;border-radius: 6px;color: #fff}
    	.
    </style>
    <title>职员明细表</title>
</head>
<body>
	
	<div class="query">
    	<div class="tabe_bot">
        	
			<div class="l_left"><label>培训名称：</label><input type="text" id="trainName"></div>
			<div class="l_left"><label>审核状态：   </label>
			<select id="status">
				<c:forEach var="cv" items="${cvstatus }">
				<option value="${cv.id }">${cv.cv_starts }</option>
			</c:forEach>
			</select>
			</div>
			<div class="l_left"><label>培训时间：</label><input id="demo01" type="text" class="startTime">至 <input id="demo02" type="text" class="overTime"></div>
        	<button class="tabe_btn " type="submit" onclick="One()">查询</button>
        	<div class="clear"></div>
    	</div>
	</div>
	
	<div class="tabe_btn" style="width: 100px;text-align: center;">
		<a href="GetAdd.html" style="color: white; padding-top: 20px">新增培训计划</a>
	</div>
	<div class="table-box">
    	<table id="table" class="table_style"></table>
	</div>
	<div class="pagination ue-clear"></div>
	
	
</body>

<script type="text/javascript" src="static/js/jquery.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/bootstrap-table.js"></script>
<script src="static/js/bootstrap-table-zh-CN.min.js"></script>
<script src="static/js/date/js/laydate.js"></script>
<script type="text/javascript"></script>
<script>
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
        laydate({elem: '#demo'});//绑定元素
        laydate({elem: '#demo01'});//绑定元素
        laydate({elem: '#demo02'});//绑定元素
    }();
</script>

<script>
	function GetAdd() {
		
		 $.ajax({
			type: "GET",
			url: "GetAdd.json"
			
		}) 
	}
</script>

<script>
	function One() {
			var trainName,status,startTime,overTime;
			trainName = $("#trainName").val();
			status = $("#status").val();
			startTime = $(".startTime").val();
			overTime = $(".overTime").val();
	    $.ajax({
	        type: "GET",
	        url: "GetAll.json",
	        dataType: "json",
	        data:{
	        	"trainName":trainName,
	        	"status":status,
	        	"startTime":startTime,
	        	"overTime":overTime
	        },
	        success : function(result) {
				if (result.data) {
					var TableData = result.data;
					
					$('#table').bootstrapTable("load", TableData);
				}
			}
	    })
	}
</script>
<script>
	
    $(function () {
        $('#table').bootstrapTable({
            method: "get",
            striped: true,
            singleSelect: false,
            url: "GetAll.json", 
            dataType: "json",
            pagination: true, //分页
            pageSize: 10,
            pageNumber: 1,
            search: false, //显示搜索框
            contentType: "application/x-www-form-urlencoded",
            queryParams: null,
            columns: [
                {
                    checkbox:"true",
                    field: 'ID',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: "培训名称",
                    field: 'trainName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '培训讲师',
                    field: 'trainLecturer',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '培训时间',
                    field: 'startTime',
                    align: 'center'
                },
                {
                    title: '培训反馈',
                    field: 'feedback',
                    align: 'center',
                    valign: 'middle',
                    	 formatter: function (value, row) {
                    		 if(value==1){
                    			 return "优";
                    		 }else if(value==2){
                    			 return "良";
                    		 }else if(value==3){
                    			 return "差";
                    		 }else{
                    			 return "--";
                    		 }
                    	 }
                },
                {
                    title: '审核状态',
                    field: 'cvstarts',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '操作',
                    field: 'id',
                    align: 'center',
                    formatter: function (value, row) {
                    	var a,b,c,d,f;
                    	var id = row.id;//获取改行数据的ID,以便查培训状态
                    	 $.ajax({
                 	        type: "GET",
                 	        url: "SelectStartById.json",
                 	        dataType: "json",
                 	       	async : false,//设置同步
                 	       data:{
               	        	"id":id //把该行的ID传到后台
               	        	},
               	     		success : function(e) {
               	     		 $.each(e,function(i,obj){
               	     			
               	     			 if(obj.cv_starts == "起草"){
               	     				a = '<a  href="cvChange.html/'+row.id+'">修改 </a>';
                                    b = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">复核 </a> ';
                                    c = '<a  href="cvDetail.html/'+row.id+'">明细 </a>';
                                    d = '<a  href="#" onclick="delectPland(\'' + row.id + '\')">删除</a> ';
                                    f = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">培训反馈 </a> ';
               	     			  	
               	     			 }
               	     			 if(obj.cv_starts == "审核中"){
               	     				a = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">修改 </a> ';
                                    b = '<a  href="recheck.html/'+row.id+'" >复核</a> ';
                                    c = '<a  href="cvDetail.html/'+row.id+'">明细 </a>';
                                    d = '<a  href="#" onclick="delectPland(\'' + row.id + '\')" style="display: none;">删除 </a> ';
                                    f = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">培训反馈 </a> ';
               	     			 }
               	     			 if(obj.cv_starts == "审核通过"){
               	     				a = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">修改 </a> ';
                                    b = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">复核 </a> ';
                                    c = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">明细 </a> ';
                                    d = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">删除 </a> ';
                                    f = '<a  href="cvFk.html/'+row.id+'">培训反馈</a> ';
               	     			 }
               	     			if(obj.cv_starts == "驳回"){
               	     				a = '<a  href="cvChange.html/'+row.id+'">修改 </a>';
                                    b = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">复核 </a> ';
                                    c = '<a  href="cvDetail.html/'+row.id+'">明细 </a>';
                                    d = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">删除 </a> ';
                                    f = '<a  href="#" onclick="openlayer(\'' + row.id + '\')" style="display: none;">培训反馈 </a> ';
               	     			 }
               	     			 
               	     			});
         						
         					}
               	        })   
               	       
                        return a+b+c+d+f;
                    }
                }
            ]
        });
    });
    
    function delectPland(id) {
    	$.ajax({
    		type: "GET",
	        url: "SelectPlanName.json",
	        dataType: "json",
	       
  	        data:{
  	        	"id":id //把该行的ID传到后台
  	        	 },
  	        success : function(a) {
	        	   $.each(a,function(i,obj){
	        		 if(confirm("确定删除"+obj.trainName+"吗?")){
	        			 deletePlanName(obj.id);
	        		 }else{
	        		  	alert("已取消删除!");
	        	 }
	        });    
	       
	      }	
		})
    }
///////////////
	function deletePlanName(id) {
		$.ajax({
    		type: "GET",
	        url: "DeletePlan.json",
	        dataType: "json",
	       
  	        data:{
  	        	"id":id //把该行的ID传到后台
  	        	 },
  	        success : function(a) {
	        	if(a.result){
	        		alert("删除成功!");
					var TableData = a.result;
					$('#table').bootstrapTable("refresh", TableData);
	        	}else{
	        		alert("删除失败!");
	        	} 
	      }	
		})
	}
    
</script>
</html>